package com.qwz.example.client;

import com.qwz.example.factory.AbstractFactory;
import com.qwz.example.product.abstractproduct.CPUApi;
import com.qwz.example.product.abstractproduct.MainBoardApi;
/**  
* @Description: 装机工程师类
* @Package com.qwz.example.client.ComputerEngineer
* @author Qiuwuzhi
* @date 2019/12/16 11:26
* @version V1.0
*/
public class ComputerEngineer {
    /**
     * 待组装的CPU
     */
    private CPUApi cpu = null;
    /**
     * 待组装的主板
     */
    private MainBoardApi mainBoard = null;

    /**
     * 组装电脑
     * @param schema 客户选择的装机方案
     */
    public void makeComputer(AbstractFactory schema){
        prepareHardWare(schema);
    }

    /**
     * 装机所需要的配件
     * @param schema 客户选择的装机方案
     */
    private void prepareHardWare(AbstractFactory schema){
        //创建cpu
        this.cpu = schema.createCPUApi();
        //创建主板
        this.mainBoard = schema.creatMainBoardApi();

        //测试硬件是否OK
        this.cpu.calculate();
        //测试是否匹配
        this.mainBoard.installCpu();
    }
}
